<?php
	include dirname(dirname(dirname(__FILE__)))."/admin/goods-manage/functions.php";
?>
<html>
	<head>
		<title>商品展示</title>
		<?php include dirname(dirname(dirname(__FILE__))).'/include/common-header.php' ?>
		<link rel="stylesheet" type="text/css" href="../../admin/goods-manage/css/goods.css"/>
		<script type="text/javascript">
			$(document).ready(function (){

				$(".goods-class").click(function(){
					$(".goods-class").removeClass("active");
					$(this).addClass("active");
					var _className=$.trim($(this).children().first().html());
					$("#goods-show").empty();
					$.ajax({
						dataType:"json",
						url:'../../admin/goods-manage/ajax/show-goods.php',
						data:{className:_className},
						success:function(data) {
							$.each(data,function(name,value){
								if(value.name!=null){
								var content='<li  class="col-sm-3 goods-li" >'+
				    			'<img src="'+value.url+'" alt="..." class="img-thumbnail" >'+
				    			'<h5 class="goods-info">'+value.name+'&nbsp&nbsp每箱数量:'+value.number+'</h5>'+
				    			'<h5 class="goods-info">单价/件:'+value.piece_price+'&nbsp&nbsp单价/箱:'+value.price+'</h5>'+	
				    			'<p class="goods-info">'+value.goods_describe+'</p>'+
				    			'</li>'
	  
								$("#goods-show").append(content);

								}

								
								});

							$(".goods-delete").on("click",function(){
							
								var _goodsName=$.trim($(this).next().val());
								var truthBeTold = window.confirm("确定要删除?");
								if (truthBeTold) {
									$.ajax({
										dataType:"text",
										url:"ajax/goods-delete.php",
										data:{goodsName:_goodsName},
										success:function(data){
											alert(data);
										},
										error:function(XMLHttpRequest, textStatus, errorThrown){
											alert("删除失败");
											
											},
										
										});
									
								} else {}

								
								
								});
						
					
							
						},
						error:function(){
							//ajax提交失败的处理函数！
							alert("获取失败");
							},
					});

					
				});
					

				
			});
		</script>
	</head>
	<body>
		<div class="container-fluid">
			<div class="row">
				<div class="col-sm-2">
					 <ul class="nav nav-pills nav-stacked" role="tablist">
		 			 <?php 
		  				$items=getGoodsClass();
		  				foreach ($items as $item)
		  				{
		  					echo '<li role="presentation" class="goods-class" 	><a href="javascript:void(0);">'.$item["name"].'</a></li>';
		  				}
		  			?>

					</ul>
				
				</div>
				<div class="col-sm-10">	
					<ul class="goods-ul" id="goods-show">
				    		

				    </ul>
					
				</div>
			</div>
		</div>
		
	</body>
</html>